package com.rem.controller;

import com.rem.domain.User;
import com.rem.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
public class MybatisController {

    @Autowired
    private UserMapper userMapper;


    @RequestMapping("/query")
    @ResponseBody
    public ModelAndView queryUserList(){
        List<User> users = userMapper.queryUserList();
        ModelAndView mv = new ModelAndView();
        mv.setViewName("user");
        mv.addObject("users",users);
        return mv;
    }
    @RequestMapping("/hello")
    public ModelAndView hello(){
        ModelAndView mv = new ModelAndView();
        mv.setViewName("index");
        return mv;
    }

}
